<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix='sec' uri='http://www.springframework.org/security/tags'%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<script type="text/javascript" src="scripts/boot.js"></script>
</head>
<body style="border: 0px; margin: 0px; padding: 0px; width: 100%;height: 100%">
<div class="mini-toolbar" style="border-bottom:0;padding:0px;">
    <table style="width:100%;">
        <tr>
            <td style="width:100%;">
            <sec:authorize url='/call_performance_salary_add.do'>
            	<a class="mini-button" iconCls="icon-add" onclick="openSetBasic();">新增</a>
            </sec:authorize>
            <sec:authorize url='/performance_salary_delete.do'>
				<a class="mini-button" iconCls="icon-remove" onclick="remove();">删除已选</a>
			</sec:authorize>
			<sec:authorize url='/call_performance_salary_edit.do'>
				<a class="mini-button" iconCls="icon-edit" onclick="edit()">修改</a>
			</sec:authorize>
			<sec:authorize url='/call_staff_down_salary.do'>
				<a class="mini-button" iconCls="icon-download" onclick="download();">下载产品信息</a>
			</sec:authorize>
<%-- 			<sec:authorize url='/call_salary_import_add.do'> --%>
				<a class="mini-button" iconCls="icon-upload" onclick="importCallSalary()">导入产品提成</a>
<%-- 			</sec:authorize> --%>
            </td>
        </tr>
    </table>
</div>
<div class="mini-fit" >
	<div id="datagrid0921" class="mini-datagrid " idField="id" pageSize="20" allowAlternating="true" 
	allowCellSelect="true" multiSelect="true" url="performance_salary_view.do" style="width:100%;height: 100%">
		<div property="columns">
			<div type="indexcolumn"></div>
			<div type="checkcolumn"></div>
			<div field="medicineName" width="30%" headerAlign="center" align="center">产品名称</div>
			<div field="number" width="30%" headerAlign="center" align="center">数量</div>
			<div field="money" width="30%" headerAlign="center" align="center">提成金额</div>
			<div field="updateTime" width="40%" headerAlign="center" align="center" allowSort="true" dataType="date" dateFormat="yyyy-MM-dd HH:mm:ss" >
				修改时间
			</div>
		</div>
	</div>
</div>
<script type="text/javascript">
mini.parse();
var grid = mini.get("datagrid0921");
grid.load();

// 新建
function openSetBasic() {
	mini.open({
        url: "call_performance_salary_add.do",
        allowResize:false,
        title: "新增绩效薪资", width: 400, height: 350,
        ondestroy: function (action) {
        	if(action == 'succ'){
        		mini.showMessageBox({
                    title: "提示",
                    showModal:false,
                    iconCls: "mini-messagebox-info",
                    message: "保存成功！",
                    timeout: 3000,
                    x: 'right',
                    y: 'bottom'
                });
	            grid.reload();
        	}
        }
    });
}

//修改
function edit() {
    var row = grid.getSelecteds();
    if (row.length > 0) {
    	if(row.length > 1) {
    		mini.alert('只能选择一条记录进行修改!');
    	} else {
	        mini.open({
	            url: "call_performance_salary_edit.do",
	            allowResize:false,
	            title: "修改绩效薪资", width: 400, height: 280,
	            onload: function () {
	                var iframe = this.getIFrameEl();
	                iframe.contentWindow.SetData(row[0]);
	            },
	            ondestroy: function (action) {
	            	if(action == 'succ'){
	            		mini.showMessageBox({
	                        title: "提示",
	                        showModal:false,
	                        iconCls: "mini-messagebox-info",
	                        message: "修改成功",
	                        timeout: 3000,
	                        x: 'right',
	                        y: 'bottom'
	                    });
	                	grid.reload();
	            	}else if(action == 'repet'){
	            		mini.alert("您选择的类别已经存在，如要修改请直接选择该类别修改");
	            	}
	            }
	        });
    	}
    } else {
    	 mini.alert("请选择一条记录");
    }
}

//删除
function remove() {
    var rows = grid.getSelecteds();
    var arr = new Array();
    $.each(rows,function(i,v){
    	arr.push(v.id);
    });
    var rids = arr.join(",");
    if (rows.length > 0) {
    	mini.confirm("确定删除选中记录？", "删除",
        function (action) {
            if (action == "ok") {
            	grid.loading("操作中，请稍后......");
                $.post("performance_salary_delete.do",{id:rids},
                 	function(data){
                 		mini.showMessageBox({
                             title: "提示",
                             showModal:false,
                             iconCls: "mini-messagebox-info",
                             message: "已删除",
                             timeout: 3000,
                             x: 'right',
                             y: 'bottom'
                         });
                 		grid.reload();
                	},"json");
            }
        });
    } else {
        mini.alert("请选择一条记录");
    }
}

function download() {
	location.href = "call_staff_down_salary.do";
}

//打开批量导入窗口
function importCallSalary(){
	mini.open({
        url: "call_salary_import_add.do",
        title: "批量导入产品提成", width: 320, height: 280,
        ondestroy: function (action) {
        	if(action == 'succ'){
        		mini.showMessageBox({
                    title: "提示",
                    showModal:false,
                    iconCls: "mini-messagebox-info",
                    message: "导入成功！",
                    timeout: 3000,
                    x: 'right',
                    y: 'bottom'
                });
	            grid.reload();
        	}
        }
    });
}
</script>
</body>
</html>